package com.javaGame.role;

import com.javaGame.frame.MainFrame;
import com.javaGame.role.enemy.EnemyRole;
import com.javaGame.util.ImageChange;

import java.awt.*;

/**
 * 火类
 */
public class Fire extends BaseRole{
    /**吐火图片*/
    public static Image[] fireImg;
    /**图片切换对象*/
    private ImageChange imageChange = new ImageChange(2);
    public Fire() {
        super(MainFrame.girl.getMink().x+120, MainFrame.girl.getMink().y - 30, 230, 100);
    }

    @Override
    public void move() {
        this.currentImg = imageChange.change(fireImg);

        for(int i=0;i<MainFrame.roleList.size();i++){
            BaseRole role = MainFrame.roleList.get(i);
            if(this.rect.intersects(role.rect) &&
                    role instanceof EnemyRole){
                EnemyRole enemy = (EnemyRole) role;
                enemy.byHit(20);
            }
        }
    }
}
